/**
 */
package org.xtext.ic.dsl.icDsl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import org.xtext.ic.dsl.icDsl.CreateDAO;
import org.xtext.ic.dsl.icDsl.Entity;
import org.xtext.ic.dsl.icDsl.IcDslPackage;
import org.xtext.ic.dsl.icDsl.Layer;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Create DAO</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.CreateDAOImpl#isBasedao <em>Basedao</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.CreateDAOImpl#getDaolayer <em>Daolayer</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.CreateDAOImpl#getFirstEntity <em>First Entity</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.CreateDAOImpl#getEntities <em>Entities</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CreateDAOImpl extends MinimalEObjectImpl.Container implements CreateDAO
{
  /**
   * The default value of the '{@link #isBasedao() <em>Basedao</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isBasedao()
   * @generated
   * @ordered
   */
  protected static final boolean BASEDAO_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isBasedao() <em>Basedao</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isBasedao()
   * @generated
   * @ordered
   */
  protected boolean basedao = BASEDAO_EDEFAULT;

  /**
   * The cached value of the '{@link #getDaolayer() <em>Daolayer</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDaolayer()
   * @generated
   * @ordered
   */
  protected Layer daolayer;

  /**
   * The cached value of the '{@link #getFirstEntity() <em>First Entity</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFirstEntity()
   * @generated
   * @ordered
   */
  protected Entity firstEntity;

  /**
   * The cached value of the '{@link #getEntities() <em>Entities</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEntities()
   * @generated
   * @ordered
   */
  protected EList<Entity> entities;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected CreateDAOImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return IcDslPackage.Literals.CREATE_DAO;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isBasedao()
  {
    return basedao;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBasedao(boolean newBasedao)
  {
    boolean oldBasedao = basedao;
    basedao = newBasedao;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CREATE_DAO__BASEDAO, oldBasedao, basedao));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Layer getDaolayer()
  {
    if (daolayer != null && daolayer.eIsProxy())
    {
      InternalEObject oldDaolayer = (InternalEObject)daolayer;
      daolayer = (Layer)eResolveProxy(oldDaolayer);
      if (daolayer != oldDaolayer)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, IcDslPackage.CREATE_DAO__DAOLAYER, oldDaolayer, daolayer));
      }
    }
    return daolayer;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Layer basicGetDaolayer()
  {
    return daolayer;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDaolayer(Layer newDaolayer)
  {
    Layer oldDaolayer = daolayer;
    daolayer = newDaolayer;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CREATE_DAO__DAOLAYER, oldDaolayer, daolayer));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Entity getFirstEntity()
  {
    if (firstEntity != null && firstEntity.eIsProxy())
    {
      InternalEObject oldFirstEntity = (InternalEObject)firstEntity;
      firstEntity = (Entity)eResolveProxy(oldFirstEntity);
      if (firstEntity != oldFirstEntity)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, IcDslPackage.CREATE_DAO__FIRST_ENTITY, oldFirstEntity, firstEntity));
      }
    }
    return firstEntity;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Entity basicGetFirstEntity()
  {
    return firstEntity;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFirstEntity(Entity newFirstEntity)
  {
    Entity oldFirstEntity = firstEntity;
    firstEntity = newFirstEntity;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CREATE_DAO__FIRST_ENTITY, oldFirstEntity, firstEntity));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Entity> getEntities()
  {
    if (entities == null)
    {
      entities = new EObjectResolvingEList<Entity>(Entity.class, this, IcDslPackage.CREATE_DAO__ENTITIES);
    }
    return entities;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case IcDslPackage.CREATE_DAO__BASEDAO:
        return isBasedao();
      case IcDslPackage.CREATE_DAO__DAOLAYER:
        if (resolve) return getDaolayer();
        return basicGetDaolayer();
      case IcDslPackage.CREATE_DAO__FIRST_ENTITY:
        if (resolve) return getFirstEntity();
        return basicGetFirstEntity();
      case IcDslPackage.CREATE_DAO__ENTITIES:
        return getEntities();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case IcDslPackage.CREATE_DAO__BASEDAO:
        setBasedao((Boolean)newValue);
        return;
      case IcDslPackage.CREATE_DAO__DAOLAYER:
        setDaolayer((Layer)newValue);
        return;
      case IcDslPackage.CREATE_DAO__FIRST_ENTITY:
        setFirstEntity((Entity)newValue);
        return;
      case IcDslPackage.CREATE_DAO__ENTITIES:
        getEntities().clear();
        getEntities().addAll((Collection<? extends Entity>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case IcDslPackage.CREATE_DAO__BASEDAO:
        setBasedao(BASEDAO_EDEFAULT);
        return;
      case IcDslPackage.CREATE_DAO__DAOLAYER:
        setDaolayer((Layer)null);
        return;
      case IcDslPackage.CREATE_DAO__FIRST_ENTITY:
        setFirstEntity((Entity)null);
        return;
      case IcDslPackage.CREATE_DAO__ENTITIES:
        getEntities().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case IcDslPackage.CREATE_DAO__BASEDAO:
        return basedao != BASEDAO_EDEFAULT;
      case IcDslPackage.CREATE_DAO__DAOLAYER:
        return daolayer != null;
      case IcDslPackage.CREATE_DAO__FIRST_ENTITY:
        return firstEntity != null;
      case IcDslPackage.CREATE_DAO__ENTITIES:
        return entities != null && !entities.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (basedao: ");
    result.append(basedao);
    result.append(')');
    return result.toString();
  }

} //CreateDAOImpl
